<template>
    <div class="flex items-center justify-between mb-4">
        <div>
            <el-button v-if="btns.includes('create')" type="primary" size="small" @click="$emit('create')"
                class="mr-3">新增</el-button>
            <el-popconfirm v-if="btns.includes('delete')" title="是否要删除选中？" confirm-button-text="确定"
                cancel-button-text="取消" @confirm.stop="$emit('delete')">
                <template #reference>
                    <el-button type="danger" size="small" class="mr-3">批量删除</el-button>
                </template>
            </el-popconfirm>
            <slot />
        </div>
        <div>
            <el-tooltip v-if="btns.includes('refresh')" effect="dark" content="刷新" placement="top">
                <el-button text @click="$emit('refresh')">
                    <el-icon :size="20">
                        <Refresh />
                    </el-icon>
                </el-button>
            </el-tooltip>
            <el-tooltip v-if="btns.includes('download')" effect="dark" content="导出数据" placement="top">
                <el-button text @click="$emit('download')">
                    <el-icon :size="20">
                        <Download />
                    </el-icon>
                </el-button>
            </el-tooltip>
        </div>
    </div>
</template>

<script setup>
import { computed } from 'vue';
const props = defineProps({
    layout: {
        type: String,
        defalut: "create,refresh"
    }
})
const btns = computed(() => props.layout.split(","))
defineEmits(['create', 'refresh', 'delete','download'])
</script>

<style>

</style>